package com.juyu.miliao.api.controller;

import com.juyu.miliao.api.service.UserChatService;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 用户聊天控制层
 * @Auther: 卜加超
 * @Date: 2019/3/12 18:09
 * @Description:
 */
@RestController
@RequestMapping("/userChat")
public class UserChatController {

    @Resource
    private UserChatService userChatService;


    /***
     * 用户免费聊天3句
     * @param outId 发起方用户
     * @param insertId 接收方主播
     */
    @GetMapping("/free/{outId}-{insertId}")
    public JSONObject getUserChat(@PathVariable("outId")long outId,@PathVariable("insertId")long insertId){
        return userChatService.getUserChat(outId,insertId);
    }

    /***
     * 用户免费聊天3句之后每次说话扣1金币
     * @param outId 发起方用户
     * @param insertId 接收方主播
     */
    @PostMapping("/toll")
    public void getUserTollChat(@RequestParam("outId")long outId, @RequestParam("insertId")long insertId,HttpServletRequest request){
       userChatService.getUserTollChat(outId,insertId,request);
    }
}
